<template>
  <div class="OrderAwaitingReviewListItem">
    <div class="OrderAwaitingReviewListItemContent">
      <div class="OrderAwaitingReviewListItemL1 van-hairline--bottom">
        <van-icon name="shop-o" :size="20"/>
        <span class="order-list-item-store-name">{{ order.storeName }}</span>
      </div>
      <van-card v-for="item in order.items" :key="item.id"
                :num="item.quantity" :price="item.totalAmount"
                :title="item.name" :thumb="item.imageUrl"/>
      <div class="AwaitingReviewActions">
        <van-button round plain size="small" type="primary" @click.stop="handleRouteToNewReview">评价</van-button>
      </div>
    </div>
    <white-space/>
  </div>
</template>

<script>
import { order as Order } from "@mall/api-services"
import { Button, Card, Icon } from "vant"
import WhiteSpace from "@/components/WhiteSpace"

export default {
  name: "OrderAwaitingReviewListItem",
  components: {
    WhiteSpace,
    [Button.name]: Button,
    [Card.name]: Card,
    [Icon.name]: Icon,
  },
  props: {
    order: Order.Order,
  },

  methods: {
    handleRouteToNewReview() {
      const { order } = this
      this.$router.push(`/orders/${order.id}/reviews/new`)
    },
  },
}
</script>

<style lang="scss" scoped>
.OrderAwaitingReviewListItem {
  .OrderAwaitingReviewListItemContent {
    background: #fff;
  }

  .OrderAwaitingReviewListItemL1 {
    padding: 8px 16px;
    display: flex;
    align-items: center;
  }

  .van-card {
    background: #fff;
  }

  .AwaitingReviewActions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
    padding: 9px;

    .van-button {
      margin-left: 9px;
      width: 80px;
    }
  }
}
</style>
